
cmake_minimum_required(VERSION 2.6)

set (TARGET_NAME "26_texture_mapping")

project(${TARGET_NAME})

set(CMAKE_CXX_STANDARD 20)

# GLSLC command to compile shaders to SPIR-V
find_program(GLSLC glslc)
# set(shader_path ${CMAKE_HOME_DIRECTORY}/assets/shaders/)
set(shader_path ${CMAKE_HOME_DIRECTORY}/)
file(GLOB shaders RELATIVE ${CMAKE_SOURCE_DIR} "${shader_path}*.vert" "${shader_path}*.frag")

add_executable(${TARGET_NAME} 26_texture_mapping.cpp stb_image.h ${shaders})

find_package(Vulkan REQUIRED)
target_include_directories(${TARGET_NAME} PUBLIC ${Vulkan_INCLUDE_DIRES})
target_link_libraries(${TARGET_NAME} Vulkan::Vulkan)

list(APPEND CMAKE_PREFIX_PATH "C:\\temp\\glm-0.9.9.8\\glm\\cmake")
find_package(glm CONFIG REQUIRED)
#target_link_libraries(${TARGET_NAME} glm)
target_include_directories(${TARGET_NAME} PUBLIC ${GLM_INCLUDE_DIRS})


list(APPEND CMAKE_PREFIX_PATH "C:\\temp\\glfw-test")
find_package(glfw3 CONFIG REQUIRED)
target_link_libraries(${TARGET_NAME} glfw)

set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT ${TARGET_NAME})

message("CMAKE_CURRENT_SOURCE_DIR : " ${CMAKE_CURRENT_SOURCE_DIR})
message("CMAKE_HOME_DIRECTORY : " ${CMAKE_HOME_DIRECTORY})

foreach(shader ${shaders})
	set(input_glsl "${CMAKE_HOME_DIRECTORY}/${shader}")
	set(output_spv "${input_glsl}.spv")
	execute_process(COMMAND "glslc" "${input_glsl}" "-o" "${output_spv}")
	# Compile shaders
	add_custom_command(TARGET ${PROJECT_NAME} PRE_BUILD
	COMMAND "glslc" "${input_glsl}" "-o" "${output_spv}")

endforeach()

# Compile shaders
# add_custom_command(TARGET ${PROJECT_NAME} PRE_BUILD
# COMMAND /bin/sh ${CMAKE_SOURCE_DIR}/resources/shaders/compile.sh)
